package sz.szsmk.citizencard.receiver;

import android.util.Log;

import com.baidu.location.BDAbstractLocationListener;
import com.baidu.location.BDLocation;

import org.greenrobot.eventbus.EventBus;

import sz.szsmk.citizencard.DaggerApplication;
import sz.szsmk.citizencard.model.network.dzbean.res.MessageEvent;
import sz.szsmk.citizencard.ui.activity.IMainActivity;
import sz.szsmk.citizencard.util.StringUtils;

public class LocationReceiver extends BDAbstractLocationListener {

    @Override
    public void onReceiveLocation(BDLocation bdLocation) {
        if(bdLocation.getLatitude()!=4.9E-324&&bdLocation.getLongitude()!=4.9E-324){
            if(!StringUtils.isEmpty((bdLocation.getCity()))&&bdLocation.getCity().contains("苏州市")){
                IMainActivity.setCurrentLocation(bdLocation);
            }
        }

        double latitude = bdLocation.getLatitude();    //获取纬度信息
        double longitude = bdLocation.getLongitude();    //获取经度信息
        //测试的假数据
//        BDLocation location=new BDLocation();
//        location.setLatitude(31.259186);
//        location.setLongitude(120.636177);
//        DaggerApplication.setCurrentLocation(location);
//        double latitude = location.getLatitude();    //获取纬度信息
//        double longitude = location.getLongitude();    //获取经度信息
        //        queryNearStandbyReq.setLatitude("31.259186");
//        queryNearStandbyReq.setLongitude("120.636177");
       // Log.e("======== location:", "经纬度======" + latitude + "------" + longitude);
        EventBus.getDefault().post(new MessageEvent(MessageEvent.CODE_LOCTION));
    }
}
